﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PersonalExpenseTracker.Configuration;
namespace PersonalExpenseTracker
{
    public partial class PreferencesUserControl : UserControl
    {
        public PreferencesUserControl()
        {
            InitializeComponent();
        }

        private void PreferencesUserControl_Load(object sender, EventArgs e)
        {
            this.SuspendLayout();

            chkAlwaysShowTrayIcon.Checked =
                ConfigurationSettings.AppSettings.AlwaysShowTrayIcon;
            chkCloseToTray.Checked =
                ConfigurationSettings.AppSettings.CloseToTray;
            chkMinimizeToTray.Checked =
                ConfigurationSettings.AppSettings.MinimizeToTray;
            chkSingleClickOnTrayToOpen.Checked =
                ConfigurationSettings.AppSettings.SingleClickOnTrayToOpen;

            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void PreferencesUserControl_VisibleChanged(object sender, EventArgs e)
        {
            if (this.Visible)
            {
                return;
            }
            ConfigurationSettings.AppSettings.AlwaysShowTrayIcon =
                chkAlwaysShowTrayIcon.Checked;
            ConfigurationSettings.AppSettings.CloseToTray =
                chkCloseToTray.Checked;
            ConfigurationSettings.AppSettings.MinimizeToTray =
                chkMinimizeToTray.Checked;
            ConfigurationSettings.AppSettings.SingleClickOnTrayToOpen =
                chkSingleClickOnTrayToOpen.Checked;

            ConfigurationSettings.SaveChanges();
        }

    }
}
